﻿using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace StructuredLightSystemUI
{
    /// <summary>
    /// 缩略图
    /// </summary>
    public partial class ConFixImage : UserControl
    {
        /// <summary> 图像控件最小尺寸 </summary>
        public const int ImageWidthMin = 80;

        /// <summary>
        /// 图像变量
        /// </summary>
        [BrowsableAttribute(true)]
        [EditorBrowsable(EditorBrowsableState.Always)]
        [Bindable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Category("自定义属性")]
        [Description("获取或设置控件显示的图像")]
        public Image ShowImage
        {
            set
            {
                conPictureBox1.ShowImage = value;
            }
            get
            {
                return conPictureBox1.ShowImage;
            }
        }
        /// <summary>
        /// 文本信息
        /// </summary>
        [BrowsableAttribute(true)]
        [EditorBrowsable(EditorBrowsableState.Always)]
        [Bindable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Category("自定义属性")]
        [Description("文本信息")]
        public override string Text
        {
            set
            {
                label1.Text = value;
            }
            get
            {
                return label1.Text;
            }
        }

        #region 构造
        /// <summary>
        /// 构造
        /// </summary>
        public ConFixImage()
        {
            InitializeComponent();
        }
        #endregion

        /// <summary>
        /// 设置控件尺寸
        /// </summary>
        /// <param name="imageWidth"></param>
        public void SetSize(int imageWidth)
        {
            if (imageWidth < ImageWidthMin)
                imageWidth = ImageWidthMin;
            this.Size = new Size(imageWidth, imageWidth + 34);
        }
    }
}
